{include file="public/header" /}
<link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
<style>
    #searchfloat {position:absolute;top:40px;right:20px;background:#F7F0A0;padding:10px;}
    #saved {position: relative;}
    #saved_sql {position:absolute;bottom:0;height:300px;background:#F7F0A0;width:100%;overflow:auto;display:none;}
    #saved_sql li {display:block;clear:both;width:100%;float:left;line-height:18px;padding:1px 0}
    #saved_sql li a{float:left;text-decoration: none;display:block;padding:0 5px;}
    #saved_sql li i{display:none;float:left;color:#06f;font-size: 14px;font-style: normal;margin-left:2px;line-height:18px;}
    #saved_sql li:hover{background:#fff;}
    #saved_sql li:hover i{display:block;cursor:pointer;}
    #database #tablename {height:205px;width:100%;padding:5px;}
    #database #tablename option{height:22px;}
    #database #subaction {height:210px;width:100%;}
    #database .select-striped > option:nth-of-type(odd) {background-color: #f9f9f9;}
    #database .dropdown-menu ul {margin:-3px 0;}
    #database .dropdown-menu ul li{margin:3px 0;}
    #database .dropdown-menu.row .col-xs-6{padding:0 5px;}
    #sqlquery {font-size:12px;color:#444;}
    #resultparent {padding:5px;}
</style>
<body class="gray-bg">
<div class="animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>在线操作</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="table_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div id="database" class=" ibox-content">
                <div class="alert alert-info">
                    可在线进行一些简单的数据库表优化或修复,查看表结构和数据。也可以进行SQL语句的操作
                </div>
                <div class="row">
                    <div class="col-xs-4">
                        <h4>查询结果</h4>
                    </div>
                    <div class="col-xs-8 text-right">
                        <form action="{:url('data/query')}" method="post" name="infoform" target="resultframe">
                            <input type="hidden" name="do_action" id="topaction" />
                            <div class="btn-group">
                                <button data-toggle="dropdown" class="btn btn-primary btn-embossed dropdown-toggle" type="button">基础查询 <span class="caret"></span>
                                </button>
                                <div class="row dropdown-menu pull-right" style="width:300px;">
                                    <div class="col-xs-6">
                                        <select class="form-control select-striped" id="tablename" name="tablename[]" multiple="multiple" id="aa">

                                            {volist name="tables" id="vo"}
                                            <option value="{$vo.Name}" title="">{$vo.Name}</option>
                                            {/volist}

                                        </select>
                                    </div>
                                    <div class="col-xs-6">
                                        <ul id="subaction" class="list-unstyled">
                                            <li><input type="submit" name="submit1" value="查看表结构" rel="viewinfo" class="btn btn-primary btn-embossed btn-sm btn-block"/></li>
                                            <li><input type="submit" name="submit2" value="查看表数据" rel="viewdata" class="btn btn-primary btn-embossed btn-sm btn-block"/></li>
                                            <li><input type="submit" name="submit3" value="优化表" rel="optimizes" class="btn btn-primary btn-embossed btn-sm btn-block" /></li>
                                            <li><input type="submit" name="submit4" value="修复表" rel="repairs" class="btn btn-primary btn-embossed btn-sm btn-block"/></li>

                                        </ul>
                                    </div>
                                    <div class="clear"></div>
                                </div>

                            </div>
                        </form>
                    </div>
                </div>

                <div class="well" id="resultparent" style="height: 400px">
                    <iframe name="resultframe" frameborder="0" id="resultframe" style="height:100%;" width="100%" height="100%"></iframe>
                </div>

                <form action="{:url('data/query')}" method="post" id="sqlexecute" name="form1" target="resultframe">
                    <input type="hidden" name="do_action" value="doquery" />
                    <div class="form-group">
                        <textarea name="sqlquery" placeholder="请输入SQL语句，支持批量查询，多条SQL以分号(;)分格" cols="60" rows="5" class="form-control" id="sqlquery"></textarea>
                    </div>

                    <input type="submit" class="btn btn-primary btn-embossed" value="执行" />
                    <input type="reset" class="btn btn-default btn-embossed" value="重置" />
                </form>
                <div id="backuplist"></div>

            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
{include file="public/footer" /}
<script>
    $(function () {

        //禁止在操作select元素时关闭dropdown的关闭事件
        $("#database").on('click', '.dropdown-menu select', function (e) {
            e.stopPropagation();
        });
        //事件按钮操作
        $("#database").on("click", "ul#subaction li input", function () {
            $("#topaction").val($(this).attr("rel"));
            return true;
        });
    });

</script>
</body>
